package cn.springcloud.fix.stomp.service;

import cn.springcloud.fix.stomp.vo.BaseResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.messaging.simp.stomp.StompHeaderAccessor;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class WsSubscribeService {

    public BaseResponse subscribe(StompHeaderAccessor headerAccessor) {
        String simpSessionId = headerAccessor.getSessionId();
        String destination = headerAccessor.getDestination();
        String userName = headerAccessor.getUser().getName();
        log.info("start subscribe withUser --> {}, simpSessionId-> {}, destination: {}", userName, simpSessionId, destination);
        // StompClientProcessor client = stompClientSessionManager.getClient(simpSessionId);
        // if (client == null) {
        //     log.error("unknown user:{}", simpSessionId);
        //     return R.fail().data("not connected");
        // }
        // StompMessageType messageType = StompMessageType.msgDestinationOf(destination);
        // client.getMessageTypes().put(messageType, messageType.text());
        log.info("end subscribe withUser --> {}, simpSessionId-> {}, destination: {}", userName, simpSessionId, destination);
        return BaseResponse.ok();
    }
}
